const modules = import.meta.glob('@/views/**/*.vue')
console.log(modules, '导入vue中');


export const menu = [
    {
        name: 'Friend',
        path: '/friend',
        component: 'friend',
        meta: {
            title: '好友',
            icon: 'UserFilled'
        }
    },
    {
        name: 'Group',
        path: '/group',
        component: 'group',
        meta: {
            title: '群聊',
            icon: 'Grid'
        }
    },
    {
        name: 'Chat',
        path: '/chat',
        component: 'chat',
        meta: {
            title: '聊天',
            icon: 'Comment'
        }
    },
    {
        name: 'Collection',
        path: '/collection',
        component: 'collection',
        meta: {
            title: '收藏',
            icon: 'Management'
        }
    },
    {
        name: 'Notice',
        path: '/notice',
        component: 'notice',
        meta: {
            title: '通知',
            icon: 'BellFilled'
        }
    },
]
const routes = menu.map(item => ({
    name: item.name,
    path: item.path,
    component: modules[`/src/views/${item.component}/index.vue`],
    meta: item.meta
})
)
const staticRoute = [
    {
        name: 'AddFriend',
        path: '/add-friend',
        component: () => import('@/views/friend/add.vue'),
        meta: {
            title: '添加好友',
            activeMenu: '/friend'
        }
    }
]
export default [
    {
        name: 'Layout',
        path: '/',
        component: () => import('@/layout/index.vue'),
        redirect: routes[0].path,
        children: [...routes, ...staticRoute],
        meta: {
            title: '首页'
        }
    },
    {
        name: 'Login',
        path: '/login',
        component: () => import('@/views/login.vue'),
        meta: {
            title: '登录'
        }
    },
    {
        path: "/404",
        name: "404",
        component: () => import("@/views/404.vue"),
        meta: {
            title: "404",
        },
    },
    {
        path: "/:pathMatch(.*)*",
        name: "Any",
        redirect: "/404",
        component: () => import("@/views/404.vue"),
        meta: {
            title: "任意路由",
        }
    }
]